from manimlib import *


def polar2xyz(rho, theta):
    return rho * np.array([np.cos(theta), np.sin(theta), 0])


class Scene01(Scene):
    def construct(self):
        theta = PI / 3
        axes = Axes(x_range=[-2, 2, 1], y_range=[-2, 2, 1], width=4, height=4)
        cir = Circle(color=BLUE, radius=1.5)
        vec = Vector(1.5 * np.array([np.cos(theta), np.sin(theta), 0])).set_color(RED)
        ang = Arc(0, theta, color=PURPLE, radius=0.4)
        tg = DashedLine(vec.get_end(), 1.5*np.array([np.cos(theta), 0, 0]), color=RED)
        phi = Tex(r"\omega t+\varphi", color=BLACK).scale(0.5).next_to(ang, buff=0.1)
        dot = Dot(1.5*np.array([np.cos(theta), 0, 0]), color=PURPLE)
        vec_a = Tex(r"\vec{A}", color=RED).scale(0.5).move_to(vec.get_vector()*1.2)
        om = Tex(r"\omega", color=BLACK).scale(0.5).move_to(polar2xyz(1.7,theta+0.3))
        vec2 = Arc(1.5, 0.5, radius=1.7, color=GOLD).add_tip(length=0.2, width=0.15)
        formula = Tex(r"x=A\cos(\omega t+\varphi)", color=BLACK).scale(0.7).shift(DOWN*0.7)
        self.add(axes, cir, vec, ang, tg, dot, vec_a, phi, om, vec2, formula)